package com.agile.major.service.impl;

import com.agile.major.domain.Internship;
import com.agile.major.repository.InternshipRepository;
import com.agile.major.service.InternshipService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


/**
 * Service Implementation for managing Internship.
 */
@Service
@Transactional
public class InternshipServiceImpl implements InternshipService{

    private final Logger log = LoggerFactory.getLogger(InternshipServiceImpl.class);

    private final InternshipRepository internshipRepository;

    public InternshipServiceImpl(InternshipRepository internshipRepository) {
        this.internshipRepository = internshipRepository;
    }

    /**
     * Save a internship.
     *
     * @param internship the entity to save
     * @return the persisted entity
     */
    @Override
    public Internship save(Internship internship) {
        log.debug("Request to save Internship : {}", internship);
        return internshipRepository.save(internship);
    }

    /**
     *  Get all the internships.
     *
     *  @param pageable the pagination information
     *  @return the list of entities
     */
    @Override
    @Transactional(readOnly = true)
    public Page<Internship> findAll(Pageable pageable) {
        log.debug("Request to get all Internships");
        return internshipRepository.findAll(pageable);
    }

    /**
     *  Get one internship by id.
     *
     *  @param id the id of the entity
     *  @return the entity
     */
    @Override
    @Transactional(readOnly = true)
    public Internship findOne(Long id) {
        log.debug("Request to get Internship : {}", id);
        return internshipRepository.findOne(id);
    }

    /**
     *  Delete the  internship by id.
     *
     *  @param id the id of the entity
     */
    @Override
    public void delete(Long id) {
        log.debug("Request to delete Internship : {}", id);
        internshipRepository.delete(id);
    }
}
